(function(){
    var $sidebar = $("#sidebar");
    if($sidebar.length == 0) return;

    $sidebar.$ = function(selector){
        return this.find(selector);
    }

    $("body").on("click", "#sidebar li", function(e){
        e.stopPropagation();
        var $li = $(e.currentTarget);
        if($li.length == 0) return;

        $sidebar.$("li").removeClass("active");
        $li.addClass("active");
        $li.closest("ul").closest("li").addClass("active");
    });

})();